package com.taojie.graduation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.taojie.graduation.domain.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CategoryMapper extends BaseMapper<Category> {
    @Select("select c.* FROM tb_pc pc, category c where pc.category_id = c.id and pc.product_id = #{id}")
    List<Category> findByProdId(@Param("id") Integer id);

    @Insert("insert into tb_pc (category_id, product_id) values (#{cateId}, #{prudId})")
    void addByProdId(@Param("prudId") Integer prudId, @Param("cateId") Integer cateId);

    @Delete("delete FROM tb_pc where product_id = #{id} ")
    int deleteByProdId(@Param("id") Integer id);
}